package adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.footballgamecollectandanalyze.R;

import java.util.List;

import bean.Myteam;

/**
 * Created by Administrator on 2017/3/29.
 */
public class MyteamAdapter extends ArrayAdapter<Myteam> {

    private int resourceId;

    public MyteamAdapter(Context context, int textViewResourceId, List<Myteam> object){
        super(context,textViewResourceId,object);

        resourceId = textViewResourceId ;
    }
    class ViewHolder {
        TextView TeamName;
        TextView Record;
        TextView Ave_Age;
        TextView Win;
    }
    @Override
    public View getView(int postion, View convertView, ViewGroup parent){
        Myteam myteam = getItem(postion);
        View view ;
        ViewHolder viewHolder = null;
        if(convertView == null)
        {
            view = LayoutInflater.from(getContext()).inflate(resourceId, null);
            viewHolder = new ViewHolder();
            viewHolder.TeamName=(TextView) view.findViewById(R.id.TeamName);
            viewHolder.Record = (TextView) view.findViewById(R.id.Record);
            viewHolder.Ave_Age = (TextView) view.findViewById(R.id.Ave_Age);
            viewHolder.Win =(TextView) view.findViewById(R.id.Win);
            view.setTag(viewHolder);
        }
        else
        {
            view =convertView ;
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.TeamName.setText(myteam.getTeamName());
        viewHolder.Ave_Age.setText(myteam.getAve_Age());
        viewHolder.Record.setText(myteam.getRecord());
        viewHolder.Win.setText(myteam.getWin());

        return view;
    }
}
